package com.fashion.utils;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

/**
 * User: Administrator
 * Date: 12-5-31
 */
public class HtmlUtils {
    public static String fetchFirstAttribute(String html, String tagName, String attributeName) {
        Document doc = Jsoup.parse(html);

        Elements elements = doc.getElementsByTag(tagName);
        if (elements.size() == 0) {
            return "";
        }

        return elements.get(0).attr(attributeName);
    }

}
